document.addEventListener('DOMContentLoaded', function () {
  var top = document.getElementsByClassName("top")[0];
  var nav = document.getElementsByClassName("nav")[0];
  console.log(nav);
  console.log(top);

  // 提取日期相关函数
  function initDate() {
    date();
  }
  initDate()
  function date() {
    var spa = document.querySelector(".dater");
    var timer = null;

    // 封装时间日期格式化
    function mydate() {
      var date = new Date();
      // 时间日期格式化 yyyy-mm-dd hh:mm:ss
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var data = date.getDate();
      var hours = date.getHours();
      var minutes = date.getMinutes();
      var seconds = date.getSeconds();
      // 补 0
      month = (month < 10) ? "0" + month : month;
      data = (data < 10) ? "0" + data : data;
      hours = (hours < 10) ? "0" + hours : hours;
      minutes = (minutes < 10) ? "0" + minutes : minutes;
      seconds = (seconds < 10) ? "0" + seconds : seconds;
      var res = `${year}年${month}月${data}日 ${hours}:${minutes}:${seconds}`;
      return res;
    }

    function automove() {
      spa.innerHTML = mydate();
    }
    // 自动走
    setInterval(automove, 1000);
  }


  // 添加点击事件
  //日志系统
  var journal = document.getElementsByClassName("journal")[0];
  journal.onclick = function () {
    location.href = "./diary.html";
  }
  //审核系统
  var vet = document.getElementsByClassName("vet")[0];
  vet.onclick = function () {
    location.href = "./audit.html";
  }
  //用户管理
  var user = document.getElementsByClassName("user")[0];
  user.addEventListener('click', function () {
    location.href = "./UserMage.html";
  });
  //班级管理
  var classs = document.getElementsByClassName("classs");
  classs[0].onclick = function () {
    location.href = "./ClassManagement.html";
  }
  //日常
  var routine = document.getElementsByClassName("routine")[0];
  routine.onclick = function () {
    location.href = "./daily.html";
  }
  //学生档案
  var archives = document.getElementsByClassName("archives")[0];
  archives.onclick = function () {
    location.href = "./student file.html";
  }
  //项目管理
  var project = document.getElementsByClassName("project")[0];
  project.onclick = function () {
    location.href = "./projectmanagement.html";
  }
  //出差记录
  var travel = document.querySelector(".travel");
  travel.addEventListener('click', function () {
    location.href = "./business.html";
  });
  //请假记录
  var excused = document.querySelector(".excused");
  excused.addEventListener('click', function () {
    location.href = "./vacate.html";
  });
  //考勤记录
  var presence = document.querySelector(".presence");
  presence.addEventListener('click', function () {
    location.href = "./clock.html";
  });
})
var titler = document.getElementsByClassName("namer")[0];
titler.innerHTML = `${localStorage.getItem('userName')}`;

